package core.modeling.metamodel;

import core.ConstantesAnaliseSemantica;
import core.generator.Codigo;
import core.generator.GeradorDeCodigoUtils;

public class Constraint {
	private String stereotype;
	private String text;

	public Constraint() {
		this.text = "";
		this.stereotype = "";
	}

	public void setPreCondition() {
		this.stereotype = ConstantesAnaliseSemantica.PRE;
	}

	public void setPostCondition() {
		this.stereotype = ConstantesAnaliseSemantica.POST;
	}

	public String getStereotype() {
		return stereotype;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public void addText(String text) {
		this.text += text;
	}

	public void addText(Codigo code) {
		addText(code.toString());
	}

	public Codigo generateJMLCode() {
		return new Codigo(
				GeradorDeCodigoUtils.oclLineToJML(GeradorDeCodigoUtils
						.oclSymbolToJML(stereotype) + " " + text + ";"));
	}
}
